        public static string getInternalIP()
        {
            IPHostEntry ipEntry = Dns.GetHostEntry(getHostName());
            IPAddress[] localip = ipEntry.AddressList;

            return localip[0].ToString();
        }

        //Coded by Rue
        public static string getExternalIP()
        {
            WebClient wc = new WebClient();
            UTF8Encoding utf8 = new UTF8Encoding();            
            string page = utf8.GetString(wc.DownloadData("http://checkip.dyndns.org/"));
            wc.Dispose();

            string ipPattern = @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b";
            Regex ipRegex = new Regex(ipPattern, RegexOptions.IgnoreCase);
            Match ipMatch = ipRegex.Match(page);
                        
            return ipMatch.Value.ToString();
        }